/*
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package hextd.tower;

import com.twolattes.json.Entity;
import com.twolattes.json.Value;
import java.util.Map;
import javax.swing.JPanel;

@Entity
public class JsonTower {

	public static enum optionKey {

		s0("Target Lock (0=off, 1=on)", "0"),
		s1("Targeting policy (0=close, 3=furthest)", "0"),
		s2("Firecontrol sync (0=same, 1=diff)", "0"),
		u("Number of upgrades", "0"),
		maxlevel("Maximum level", "10"),
		budget("Starting budget", "100"),
		incomedelay("# of ticks between income", "50"),
		incomefactor("Fraction of income received", "0.25"),
		incomestart("Starting income", "10"),
		creeptypes("Used creep types (0=rr, 8=hh)", "0,1,2,3"),
		creepticks("# of ticks per creep type", "600"),
		creepsizes("Used creep sizes (0=N, 1=S, 2=L)", "0,1,2");
		public final String description;
		public final String defaultValue;

		private optionKey(String description, String defaultValue) {
			this.description = description;
			this.defaultValue = defaultValue;
		}
	}
	@Value
	public int row;
	@Value
	public int col;
	@Value
	public int owner;
	@Value
	public TowerFactory.type type;
	@Value(optional = true)
	public Map<String, String> options;
//
	private JsonTowerPanel settingsPanel;

	@Override
	public String toString() {
		return type.toString() + " (" + row + "," + col + ")";
	}

	public JPanel getSettingsPanel() {
		if (settingsPanel == null) {
			settingsPanel = new JsonTowerPanel(this);
		}
		return settingsPanel;
	}
}
